﻿using System;
using MySql.Data.MySqlClient;

namespace com.orange.examination
{
    public partial class TeacherManage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Session["teacher"] == null)//禁止匿名登录
            {
                Response.Redirect("../LoginAndRegister/Login.aspx");
            }
            else
            {
                lbuserID.Text = Session["teacher"].ToString();//教师编号
            MySqlConnection conn = BaseClass.DBCon();//连接数据库
            conn.Open();//打开连接
            MySqlCommand cmd = new MySqlCommand("select * from tb_Teacher where TeacherNum='" + lbuserID.Text + "'", conn);
            MySqlDataReader sdr = cmd.ExecuteReader();//创建记录集
            sdr.Read();
            lbname.Text = sdr["TeacherName"].ToString();//显示教师姓名
            lblkc.Text = sdr["TeacherCourse"].ToString();
            //int id = Convert.ToInt32(sdr["TeacherCourse"].ToString());
            //sdr.Close();
            //cmd = new MySqlCommand("select LessonName from tb_Lesson where ID=" + id, conn);
            //lblkc.Text = cmd.ExecuteScalar().ToString();
            Session["KCname"] = lblkc.Text;
            conn.Close();//关闭连接
            }
        }
    }
}